import {
  q as c,
  p as V,
  ap as M,
  X as B,
  f as R,
  H as T,
  av as E,
  aw as O,
  k as t,
  m as s,
  l as u,
  az as H,
  as as n,
  aG as j,
  at as y
} from "./index-30f27935.js";
import { f as F } from "./finance-301595de.js";
function P(v) {
  const g = c([]),
    l = c(!0);
  c({}), V();
  const x = c(1),
    d = c(10),
    C = M("reload"),
    p = B({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    b = B({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    A = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "ID", prop: "user_id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      {
        label: "升级前级别",
        prop: "old_place",
        minWidth: 80,
        formatter: ({ old_place: e }) => {
          if (e == 0)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [s("暂无")] }
            );
          if (e == 1)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星合伙人")] }
            );
          if (e == 2)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星合伙人")] }
            );
          if (e == 3)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星合伙人")] }
            );
          if (e == 4)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("四星合伙人")] }
            );
          if (e == 5)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("五星合伙人")] }
            );
          if (e == 6)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星联创")] }
            );
          if (e == 7)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星联创")] }
            );
          if (e == 8)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星联创")] }
            );
          if (e == 9)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("四星联创")] }
            );
          if (e == 10)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星董事")] }
            );
          if (e == 11)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星董事")] }
            );
          if (e == 12)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星董事")] }
            );
        }
      },
      {
        label: "升级后级别",
        prop: "new_place",
        minWidth: 80,
        formatter: ({ new_place: e }) => {
          if (e == 0)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [s("暂无")] }
            );
          if (e == 1)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星合伙人")] }
            );
          if (e == 2)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星合伙人")] }
            );
          if (e == 3)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星合伙人")] }
            );
          if (e == 4)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("四星合伙人")] }
            );
          if (e == 5)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("五星合伙人")] }
            );
          if (e == 6)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星联创")] }
            );
          if (e == 7)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星联创")] }
            );
          if (e == 8)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星联创")] }
            );
          if (e == 9)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("四星联创")] }
            );
          if (e == 10)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星董事")] }
            );
          if (e == 11)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星董事")] }
            );
          if (e == 12)
            return t(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星董事")] }
            );
        }
      },
      { label: "备注", prop: "content", minWidth: 80 },
      { label: "创建时间", prop: "create_time", minWidth: 100 }
    ],
    W = R(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function D(e) {
    H(e);
  }
  async function S(e) {
    const r = { role_id: e.role_id },
      i = JSON.stringify(r),
      f = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(i)) },
      a = await j(f);
    a.code == 200
      ? (y("删除成功", { type: "success" }), C())
      : y(a.msg, { type: "error" });
  }
  function I() {}
  function J(e) {
    (d.value = e), h(void 0, e);
  }
  function k(e) {
    (x.value = e), h(e, void 0);
  }
  function z(e) {}
  function U(e) {
    (b.text = `正在加载第${e}页...`),
      (l.value = !0),
      E(600).then(() => {
        l.value = !1;
      });
  }
  async function L(e) {
    l.value = !0;
    const r = {
        page: 1,
        pagesize: d.value,
        content: "place",
        user_phone: e.user_phone,
        type: e.type
      },
      i = JSON.stringify(r),
      f = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(i)) },
      { data: a } = await F(f);
    (g.value = a.place.data),
      (p.total = a.place.total),
      setTimeout(() => {
        l.value = !1;
      }, 500);
  }
  async function h(e = x.value, r = d.value) {
    const m = JSON.stringify({ page: e, pagesize: r, content: "place" }),
      a = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(m)) },
      o = await F(a);
    o.code === 200
      ? ((g.value = o.data.place.data),
        (p.total = o.data.place.total),
        setTimeout(() => {
          l.value = !1;
        }, 500))
      : y(o.msg, { type: "error" });
  }
  const N = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    T(() => {
      E().then(() => {
        const { setWatermark: e } = O(v.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        h();
    }),
    {
      loading: l,
      columns: A,
      dataList: g,
      pagination: p,
      buttonClass: W,
      onSearch: L,
      resetForm: N,
      handleaddUser: I,
      handleUpdate: D,
      handleDelete: S,
      handleSizeChange: J,
      handleCurrentChange: k,
      handleSelectionChange: z,
      onCurrentChange: U
    }
  );
}
export { P as useRole };
